﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Product.ascx.cs" Inherits="UserControls_Product" %>
<%@Import namespace="ProductServiceReference" %>
<% var client = new ProductServiceClient();
   var products = client.GetProducts();
   var catid = int.Parse(Request.QueryString["catid"] ??"0");
   var productsByCategory = client.GetProductByCategory(catid);
   if (productsByCategory != null && catid != 0)
   {
        foreach (var product in productsByCategory)
       {
            %>
                <div class="product">
            	    <a href="ProductDetails.aspx?prodid=<%=product.ProductID %>"><%=product.ProductName %></a>
            	    <img src="<%=product.ProductImage %>" alt="image"/>
                    Price:<%=product.Price %> $
                </div>  
            <%
       }   
   }
   else if(catid == 0)
   {    
        foreach (var product in products)
       {
            %>
                <div class="product">
            	    <a href="ProductDetails.aspx?prodid=<%=product.ProductID %>"><%=product.ProductName %></a>
            	    <img src="<%=product.ProductImage %>" alt="image"/>
                    Price:<%=product.Price %> $
                </div>  
            <%
       }
   }

  
%>
      
        